/**
 *====================================================
 * 文件名称: ContainerBulkstockHistoryServiceImpl.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2016年5月24日			chenxy(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.common.util.BeanUtils;
import com.yuexunit.finance.project.entity.ContainerBulkstockHistoryEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;

/**
 * @ClassName: ContainerBulkstockHistoryServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2016年5月24日 下午5:05:22
 */
@Implements(ContainerBulkstockHistoryService.class)
public class ContainerBulkstockHistoryServiceImpl implements ContainerBulkstockHistoryService {

	@Override
	public Long createContainerBulkstock(ContainerBulkstockHistoryEntity entity) {
		if (entity.getAbnormal() == null) {
			entity.setAbnormal(Boolean.TRUE);
		}
		PersistUtil.insert(entity);
		return entity.getBulkstockHistoryId();
	}

	@Override
	public void updateContainerBulkstock(ContainerBulkstockHistoryEntity entity) {
		ContainerBulkstockHistoryEntity persist = inquireContainerBulkstock(entity.getBulkstockHistoryId());
		BeanUtils.copyProperties(entity, persist);
		PersistUtil.update(persist);
	}

	@Override
	public void renovateContainerBulkstock(ContainerBulkstockHistoryEntity persist) {
		PersistUtil.update(persist);
	}

	@Override
	public void deleteContainerBulkstock(Long bulkstockHistoryId) {
		PersistUtil.delete(ContainerBulkstockHistoryEntity.class, bulkstockHistoryId);
	}

	@Override
	public ContainerBulkstockHistoryEntity inquireContainerBulkstock(Long bulkstockHistoryId) {
		return PersistUtil.get(ContainerBulkstockHistoryEntity.class, bulkstockHistoryId);
	}

	@Override
	public List<ContainerBulkstockHistoryEntity> inquireTallyingContainerBulkstockList(Long tallyingId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(ContainerBulkstockHistoryEntity.class);
		criteria.add(Restrictions.eq("tallyingId", tallyingId));
		return PersistUtil.get(criteria);
	}

	@Override
	public List<ContainerBulkstockHistoryEntity> inquireContainerHistoryBulkstockList(Long inventoryHistoryId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(ContainerBulkstockHistoryEntity.class);
		criteria.add(Restrictions.eq("inventoryHistoryId", inventoryHistoryId));
		return PersistUtil.get(criteria);
	}

}
